package com.victor;

import com.victor.config.properties.VictorProperties;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.scheduling.annotation.EnableScheduling;
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter;



/**
 * @Auther:Victor
 * @Description: SpringBoot方式启动类
 * @Date:Create in 10:15 2018/3/23
 * @Modified By:
 */
@SpringBootApplication
@EnableScheduling
public class App extends WebMvcConfigurerAdapter {
    protected final static Logger logger = LoggerFactory.getLogger(App.class);

    @Autowired
    VictorProperties victorProperties;

    /**
     * @Auther:Victor
     * @Description: 增加swagger支持
     * @Date:Create in 10:13 2018/3/23
     * @Modified By:
     */
    @Override
    public void addResourceHandlers(ResourceHandlerRegistry registry) {
        if (victorProperties.getSwaggerOpen()) {
            registry.addResourceHandler("swagger-ui.html").addResourceLocations("classpath:/META-INF/resources/");
            registry.addResourceHandler("/webjars/**").addResourceLocations("classpath:/META-INF/resources/webjars/");
        }
    }

    /**
     * @Auther:Victor
     * @Description: 主运行方法
     * @Date:Create in 10:15 2018/3/23
     * @Modified By:
     */
    public static void main(String[] args) {
        SpringApplication.run(App.class, args);
        logger.info("Highset is sussess!");
    }

}
